import {getRequest, postRequest} from "@/utils/request.js";

export async function addOpinion(fatherId, tittle, content) {
    try {
        return await postRequest('/dx-m/option/add',
            {fatherId, tittle, content});
    }catch (e) {
        console.log('发送失败',e);
        return {code: -1, msg: `发送失败-${e.message}`}
    }
}

export async function listOpinion(model, opinionId) {
    try {
        return await getRequest('/dx-m/option/list',
            {model, opinionId});
    }catch (e) {
        console.log('获取opinion失败',e);
        return {code: -1, msg: `获取opinion失败-${e.message}`}
    }
}

export async function queryById(opinionId) {
    try {
        return await getRequest('/dx-m/option/getOne',
            {opinionId});
    }catch (e) {
        console.log('通过ID获取opinion失败',e);
        return {code: -1, msg: `通过ID获取opinion失败-${e.message}`}
    }
}

export async function handleOpinion(handleType, opinionId, userId,
                                    status, fatherId, tittle, content, createTime) {
    try {
        return await postRequest('/dx-m/option/handle',
            {handleType, opinionId, userId,
                status, fatherId, tittle, content, createTime});
    }catch (e) {
        console.log('更新opinion失败',e);
        return {code: -1, msg: `更新opinion失败-${e.message}`}
    }
}